<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="X-UA-Compatible" content="IE=edge"><title> RISC-V simulator · shawlley</title><meta name="description" content="RISC-V simulator - shawlley"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/icon.png"><link rel="stylesheet" href="/css/apollo.css"><link rel="search" type="application/opensearchdescription+xml" href="http://example.com/atom.xml" title="shawlley"><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="shawlley" type="application/atom+xml">
</head><body><div class="wrap"><header><a href="/" class="logo-link"><img src="/icon.png" alt="logo"></a><ul class="nav nav-list"><li class="nav-list-item"><a href="/" target="_self" class="nav-list-link">BLOG</a></li><li class="nav-list-item"><a href="/archives/" target="_self" class="nav-list-link">ARCHIVE</a></li><li class="nav-list-item"><a href="https://github.com/Shawlleyw" target="_blank" class="nav-list-link">GITHUB</a></li></ul></header><main class="container"><div class="post"><article class="post-block"><h1 class="post-title">RISC-V simulator</h1><div class="post-info">Sep 22, 2022</div><div class="post-content"><p>A circuit CPU simulator built on logism platfrom which supports basic RISC-V instructions.</p>
<span id="more"></span>

<h1 id="rv-emu"><a href="#rv-emu" class="headerlink" title="rv-emu"></a>rv-emu</h1><p>将<code>rv-cpu.circ</code>导入至logism软件中进行电路仿真</p>
<p><img src="/images/rv-emu/table.png" alt="table"></p>
<h2 id="信号生成"><a href="#信号生成" class="headerlink" title="信号生成"></a>信号生成</h2><p>查阅risc-v指令集对应指令并将对应段填入<code>auto-gen.xlsx</code>中，会自动生成各个信号的表达式，填入信号控制器即可</p>
<h2 id="单周期指令"><a href="#单周期指令" class="headerlink" title="单周期指令"></a>单周期指令</h2><p>支持基本指令，每条指令为一个周期</p>
<p><img src="/images/rv-emu/single_cycle.png" alt="single-cycle"></p>
<h2 id="流水线"><a href="#流水线" class="headerlink" title="流水线"></a>流水线</h2><p><strong>理想流水线</strong></p>
<p>无分支指令，无数据冲突</p>
<p><img src="/images/rv-emu/ideal_pipeline.png" alt="ideal-pipeline"></p>
<p><strong>气泡流水线</strong></p>
<p>在出现分支结构与数据冲突时插入气泡暂停流水线</p>
<p><img src="/images/rv-emu/stall_pipeline.png" alt="stall-pipeline"></p>
<p><strong>重定向流水线</strong></p>
<p>数据冲突时不插入气泡，而是将流水线后段的数据重定向转发至前段，拥有比气泡流水线更好的性能</p>
<p><img src="/images/rv-emu/data_redirection_pipeline.png" alt="data-redirection"></p>
<h2 id="中断"><a href="#中断" class="headerlink" title="中断"></a>中断</h2><p>具有优先级的多级嵌套中断</p>
<p><img src="/images/rv-emu/multi-level_interruption.png" alt="multi-level-interruption"></p>
</div></article></div></main><footer><div class="paginator"><a href="/2022/10/01/A-tool-for-NoC-visualization/" class="prev">PREV</a><a href="/2022/08/17/A-interesting-concurrency-bug-with-golang/" class="next">NEXT</a></div><div class="copyright"><p>© undefined - 2022 <a href="http://example.com">shawlley</a>, powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/pinggod/hexo-theme-apollo" target="_blank">hexo-theme-apollo</a>.</p></div></footer></div><script async src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML" integrity="sha384-crwIf/BuaWM9rM65iM+dWFldgQ1Un8jWZMuh3puxb8TOY9+linwLoI7ZHZT+aekW" crossorigin="anonymous"></script></body></html>